package com.gilight.base.controller;

import com.gilight.base.base.ResultEntity;
import com.gilight.base.model.SysIcon;
import com.gilight.base.service.SysIconService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/web/icon")
public class SysIconController {

    @Autowired
    private SysIconService sysIconServiceImpl;

    @ApiOperation("查询图标列表")
    @RequestMapping(value = "/findIconList", method = {RequestMethod.GET})
    public ResultEntity findList() {
        ResultEntity resultEntity = new ResultEntity();
        resultEntity.setData(sysIconServiceImpl.findList());
        return resultEntity;
    }

    @ApiOperation("查询图标")
    @RequestMapping(value = "/findIcon", method = {RequestMethod.GET})
    public ResultEntity selectByPrimaryKey(@RequestParam(value="id") Long id) {
        ResultEntity resultEntity = new ResultEntity();
        resultEntity.setData(sysIconServiceImpl.selectByPrimaryKey(id));
        return resultEntity;
    }

    @ApiOperation("增加图标")
    @RequestMapping(value = "/addIcon", method = {RequestMethod.POST})
    public ResultEntity addIcon(@RequestBody @Validated SysIcon sysIcon) {
        ResultEntity resultEntity = new ResultEntity();
        sysIconServiceImpl.addIcon(sysIcon);
        resultEntity.setData(sysIcon);
        return resultEntity;
    }
    @ApiOperation("修改图标")
    @RequestMapping(value = "/updateIcon", method = {RequestMethod.POST})
    public ResultEntity updateIcon(@RequestBody @Validated SysIcon sysIcon) {
        ResultEntity resultEntity = new ResultEntity();
        sysIconServiceImpl.updateIcon(sysIcon);
        resultEntity.setData(sysIcon);
        return resultEntity;
    }
    @ApiOperation("删除图标")
    @RequestMapping(value = "/deleteIconById", method = {RequestMethod.GET})
    public ResultEntity deleteIconById(@RequestParam(value="id") Long id) {
        ResultEntity resultEntity = new ResultEntity();
        sysIconServiceImpl.deleteIconById(id);
        return resultEntity;
    }

    @ApiOperation("批量删除")
    @RequestMapping(value = "/deleteIconBatch", method = {RequestMethod.GET})
    public ResultEntity deleteIconBatch(@RequestParam(value = "ids") String[] ids) {
        ResultEntity resultEntity = new ResultEntity();
        sysIconServiceImpl.deleteIconBatch(ids);
        return resultEntity;
    }

}
